<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="../inc/conn.asp"-->
<!--#include file="../inc/md5.asp"-->
<!--#include file="../common/admin.asp"-->
<%
key=request.QueryString("key")
SellerID=request.QueryString("SellerID")
Itemnumber=request.QueryString("Itemnumber")
uid=request.QueryString("uid")
startTime=request.QueryString("startTime")
EndTime=request.QueryString("EndTime")
promark=request.QueryString("promark")
mark=request("mark")
pay=request.QueryString("pay")
search=request.QueryString("search")

select case request("mark")
case 1: title="中标待处理商品" : sqlsearch=" and mark<=1 and type=2"
case 2: title="待二次付款商品" : sqlsearch=" and mark=2"
case 3: title="已支付商品" : sqlsearch=" and mark=3"
case 4: title="等待卖家发货商品" : sqlsearch=" and mark=4"
case 5: title="已入库的商品" : sqlsearch=" and mark=5"
case 6: title="已创建包裹的商品" : sqlsearch=" and mark=6"
case 7: title="日本已寄出商品商品" : sqlsearch=" and mark=7"
case 8: title="已签收的商品" : sqlsearch=" and mark=8"
end select

if search="搜索" then
	  if key<>"" then
			sqlsearch=sqlsearch+" and (Itemnumber like '%"&key&"%' or uid like '%"&replace(key,"U","")&"%')"
	  end if
	  if SellerID<>"" then
			sqlsearch=sqlsearch+" and (SellerID like '%"&SellerID&"%')"
	  end if
	  if Itemnumber<>"" then
			sqlsearch=sqlsearch+" and (Itemnumber like '%"&Itemnumber&"%')"
	  end if
	  if uid<>"" then
			sqlsearch=sqlsearch+" and uid='"&uid&"'"
	  end if
	  if promark<>"" then
			sqlsearch=sqlsearch+" and mark="&promark&""
	  end if
	  if startTime<>"" and EndTime<>"" then
			sqlsearch=sqlsearch+" and Convert(char(10),WarehouseTime,20)>=Convert(char(10),'"&startTime&"',20) and Convert(char(10),WarehouseTime,20)<=Convert(char(10),'"&EndTime&"',20) "
	  end if
end if
'分页-------------------------------------------------------
set Rs=server.CreateObject("ADODB.RecordSet")
sql="select count(sortid) from (Select ROW_NUMBER() OVER (order by id desc ) as sortid,* From AuctionsOrder) as TempTable where 1=1 "&sqlsearch&""
Pager_Pagesize=10 '每页记录数
Rs.open sql,conn,1,1
Pager_TotalRecord=Rs(0) '总记录数
Rs.close
Pager_PageCount=int((Pager_TotalRecord/Pager_Pagesize)+0.99999) '计算总页数
CurrentPage=Request("page") '当前页
'如果不为数字则直接设置页码为1
if isnumeric(CurrentPage)=False Or CurrentPage="" then
	CurrentPage=1
'如果当前页数大于总页数，则直接设置页码为1
elseif  Clng(CurrentPage)>Pager_PageCount then
	CurrentPage=1
end if
Fieldsname=" id,uid,pic,url,title,Itemnumber,WarehouseNumber,paymentinfo,bidmark,Endtime,price,Realprice,SellerID,WarehouseTime,rate,TransportCost,ServiceCost,TransferCost,PackageTime,Weight,mark,BidsPrice,bail,type,addtime,sortid"
orderBy=" Order by sortid asc"
'拆分SQL语句，必须是select开头，有唯一标识的列
if instr("select",sql)<>-1 then
	if CurrentPage = 1 then
		sql = replace(sql,"select count(sortid)"," select  top " & Pager_Pagesize  & Fieldsname)
	else  
		sql = replace(sql,"select count(sortid)"," select  top " & Pager_Pagesize   & Fieldsname) & " and sortid >(select max(sortid) from (" & replace(sql,"select count(sortid)"," select  top " & Pager_Pagesize * (CurrentPage - 1)  & Fieldsname) & orderBy & ") AA)"
	end if
end if
sql = sql & orderBy
Rs.open sql,conn,1,1
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>main</title>
<link href="../css/style.css" rel="stylesheet" type="text/css"/>
<script language="javascript" type="text/javascript" src="../My97DatePicker/WdatePicker.js"></script>
</head>

<body>
<div class="main">
  <div class="main-title">查看</div>
  <div class="main-content">
  <table width="100%" border="0" cellspacing="1" cellpadding="3" class="tab">
  <tr>
    <td colspan="6" align="center">
    <form name="form" method="get" action="">
    商品名<input name="key" type="text" id="key" value="<%=key%>" maxlength="50" />
     标号<input name="Itemnumber" type="text" id="Itemnumber" value="<%=Itemnumber%>" maxlength="50" />
      卖家ID<input name="SellerID" type="text" id="SellerID" value="<%=SellerID%>" maxlength="50" />
      UID<input name="uid" type="text" id="uid" value="<%=uid%>" maxlength="50" />
      
      
      <%if mark="5" then%>
      入库时间<input name="StartTime" type="text" class="Wdate" id="startTime" onFocus="var EndTime=$dp.$('EndTime');WdatePicker({onpicked:function(){EndTime.focus();},maxDate:'#F{$dp.$D(\'EndTime\')}'})" value="<%=startTime%>" size="10" readonly="readonly" /> - <input name="EndTime" type="text" class="Wdate" id="EndTime" onFocus="WdatePicker({minDate:'#F{$dp.$D(\'startTime\')}'})" value="<%=EndTime%>" size="10" readonly="readonly" />
      状态<select name="promark" id="promark">
    <option value="">全部</option>
    <option value="5">在库</option>
    <option value="6">打包中</option>
    <option value="8">已寄出</option>
    </select>
    <%end if%>
    
    
      
      
    <input name="mark" type="hidden" value="<%=request("mark")%>" />
    <input type="submit" name="search" value="搜索" />
    </form>
    </td>
    </tr>
    </table>
  <table width="100%" border="0" cellspacing="1" cellpadding="3" class="tab">
  <form action="" method="post">
  <tr>
    <td align="center" bgcolor="#FFFFFF"><strong>选择</strong></td>
    <td align="center" bgcolor="#FFFFFF"><strong>卖家ID</strong></td>
    <td align="center" bgcolor="#FFFFFF"><strong><span class="items">标号</span></strong></td>
    <td align="center" bgcolor="#FFFFFF">会员ID</td>
    <td align="center" bgcolor="#FFFFFF">图片</td>
    <td align="center" bgcolor="#FFFFFF"><strong>名称</strong></td>
    <td align="center" bgcolor="#FFFFFF"><strong>中标价格</strong></td>
    <td align="center" bgcolor="#FFFFFF"><strong>转账费</strong></td>
    <td align="center" bgcolor="#FFFFFF"><strong>运费</strong></td>
    <td align="center" bgcolor="#FFFFFF"><strong>服务费</strong></td>
    <td align="center" bgcolor="#FFFFFF"><strong>保证金</strong></td>
    <td align="center" bgcolor="#FFFFFF"><strong>二次结余金额</strong></td>
    <td align="center" bgcolor="#FFFFFF"><strong>入库时间</strong></td>
    <td align="center" bgcolor="#FFFFFF"><strong>创建包裹时间</strong></td>
    <td align="center" bgcolor="#FFFFFF"><strong><span class="items">状态</span></strong></td>
    <td align="center" bgcolor="#FFFFFF"><strong>操作</strong></td>
    <td bgcolor="#FFFFFF">付款信息</td>
    <td bgcolor="#FFFFFF"><strong>添加时间</strong></td>
    </tr>
    <%do while not Rs.eof%>
  <tr>
    <td align="center" bgcolor="#FFFFFF"><input type="checkbox" name="checkbox" id="checkbox" value="<%=rs("id")%>" <%
	
	if request.QueryString("mark")="1" and (rs("Realprice")="0" or rs("TransferCost")="0" or rs("TransportCost")="0" or rs("ServiceCost")="0") then response.Write " disabled"
	if request.QueryString("mark")="4" and rs("Weight")="0" then response.Write " disabled"
	
	%> />
      <input type="hidden" name="wid" value="<%=rs("id")%>" /></td>
    <td align="center" bgcolor="#FFFFFF"><a target="_blank" href="http://store.auctions.yahoo.co.jp/html/profile/<%=rs("SellerID")%>.html"><%=rs("SellerID")%></a> <a target="_blank" href="http://rating.auctions.yahoo.co.jp/jp/show/rating?userID=<%=rs("SellerID")%>">评价</a></td>
    <td align="center" bgcolor="#FFFFFF"><%=rs("Itemnumber")%></td>
    <td align="center" bgcolor="#FFFFFF"><%=RS("uid")%></td>
    <td align="center" bgcolor="#FFFFFF"><a target="_blank" href="<%=rs("url")%>"><img src="<%=rs("pic")%>" height="40" width="40"></a></td>
    <td bgcolor="#FFFFFF" title="<%=rs("title")%>"><a target="_blank" href="<%=rs("url")%>"><%=left(rs("title"),10)%>.</a></td>
    <td align="center" bgcolor="#FFFFFF"><%if request.QueryString("mark")<=1 then%><input name="Realprice<%=rs("id")%>" type="text" class="input" id="Realprice<%=rs("id")%>" style="width:40px" value="<%=rs("Realprice")%>" />日元<%else%><%=rs("Realprice")%>日元<%end if%></td>
    <td align="center" bgcolor="#FFFFFF"><%if request.QueryString("mark")<=1 then%><input name="TransferCost<%=rs("id")%>" type="text" class="input" id="TransferCost<%=rs("id")%>" style="width:40px" value="<%=rs("TransferCost")%>" />日元<%else%><%=rs("TransferCost")%>日元<%end if%></td>
    <td align="center" bgcolor="#FFFFFF"><%if request.QueryString("mark")<=1 then%><input name="TransportCost<%=rs("id")%>" type="text" class="input" id="TransportCost<%=rs("id")%>" style="width:40px" value="<%=rs("TransportCost")%>" />日元<%else%><%=rs("TransportCost")%>日元<%end if%></td>
    <td align="center" bgcolor="#FFFFFF"><%if request.QueryString("mark")<=1 then%><input name="ServiceCost<%=rs("id")%>" type="text" class="input" id="ServiceCost<%=rs("id")%>" style="width:40px" value="<%=rs("ServiceCost")%>" />日元<%else%><%=rs("ServiceCost")%>日元<%end if%></td>
    <td align="center" bgcolor="#FFFFFF"><%=rs("bail")%>RMB</td>
    <td align="center" bgcolor="#FFFFFF" style="color:red">
	<%
	if rs("rate")="0" then
	response.Write FormatNumber(((cdbl(rs("Realprice"))+cdbl(rs("TransferCost"))+cdbl(rs("TransportCost"))+cdbl(rs("ServiceCost")))*web_rate)-cdbl(rs("bail")),2,-1)
	else
	response.Write FormatNumber(((cdbl(rs("Realprice"))+cdbl(rs("TransferCost"))+cdbl(rs("TransportCost"))+cdbl(rs("ServiceCost")))*cdbl(rs("rate")))-cdbl(rs("bail")),2,-1)
	end if
	%>RMB</td>
    <td align="center" bgcolor="#FFFFFF"><%=rs("WarehouseTime")%></td>
    <td align="center" bgcolor="#FFFFFF"><%=rs("PackageTime")%></td>
    <td align="center" bgcolor="#FFFFFF">
	
    <%
	  select case rs("mark")
	  case 1: response.Write "中标待处理商品"
	  case 2: response.Write "待二次付款商品"
	  case 3: response.Write "已支付商品"
	  case 4: response.Write "等待卖家发货商品"
	  case 5: response.Write "已入库的商品"
	  case 6: response.Write "已创建包裹的商品"
	  case 7: response.Write "日本已寄出商品商品"
	  case 8: response.Write "已签收的商品"
	  end select
	  %>
    
    </td>
    <td align="left" bgcolor="#FFFFFF"><%if request.QueryString("mark")="4" then%>
    
    库位号<input name="WarehouseNumber<%=rs("id")%>" type="text" class="input" style="width:40px" value="<%=rs("WarehouseNumber")%>" /><br />
    
    重　量<input name="Weight<%=rs("id")%>" type="text" class="input" style="width:40px" value="<%=rs("Weight")%>" />克(g)<%else%>库位号：<%=rs("WarehouseNumber")%> 重量：<%=rs("Weight")%>克<%end if%></td>
    <td bgcolor="#FFFFFF" title="<%=rs("paymentinfo")%>"><%if request.QueryString("mark")="3" then%><textarea name="paymentinfo<%=rs("id")%>" cols="20" rows="6"><%=rs("paymentinfo")%></textarea><%else%><%=left(rs("paymentinfo"),10)%><%end if%></td>
    <td bgcolor="#FFFFFF"><%=rs("addtime")%></td>
    </tr>
    <%
	Rs.movenext
	loop
	Rs.close
	Set Rs=nothing
	%>
    <tr>
      <td colspan="18" align="center" bgcolor="#FFFFFF" class="page">
              
           
            
            <%
			select case request.QueryString("mark")
	  case 1: response.Write "中标待处理商品   <input type=""submit"" name=""button"" value=""保存价格"">"
	  case 2: response.Write "待二次付款商品  <input type=""submit"" name=""button"" value=""已支付商品"">"
	  case 3: response.Write "待二次付款商品   <input type=""submit"" name=""button"" value=""完成支付""> <input type=""submit"" name=""button"" value=""保存付款信息"">"
	  case 4: response.Write "等待卖家发货商品   <input type=""submit"" name=""button"" value=""保存商品重量""><input type=""submit"" name=""button"" value=""已入库的商品"">"
	  case 5: response.Write "已入库的商品   "
	  case 6: response.Write "已创建包裹的商品   <input type=""submit"" name=""button"" value=""日本已寄出商品商品"">"
	  case 7: response.Write "日本已寄出商品商品   <input type=""submit"" name=""button"" value=""已签收的商品"">"
	  case 8: response.Write "已签收的商品"
	  end select
	  %>
            
            
      </td>
    </tr>
    </form>
    <tr>
    <td colspan="18" align="center" bgcolor="#FFFFFF" class="page">　
      <%
	siteurl=request.servervariables("document_name")
	%>
    <form action="<%=siteurl%>" method="get">
    共 <%=Pager_TotalRecord%> 条 第<%=CurrentPage%>页 / 共 <%=Pager_PageCount%> 页
		<%
		pageurl="key="&key&"&startTime="&startTime&"&EndTime="&EndTime&"&promark="&promark&"&Itemnumber="&Itemnumber&"&SellerID="&SellerID&"&uid="&uid&"&pay="&pay&"&mark="&mark&"&search="&search&"&"
		if CurrentPage=1 then
			response.Write(" 首页 ")
			response.Write(" 上一页 ")
		else
			response.Write(" <a href='"&siteurl&"?"&pageurl&"page=1'>首页</a> ")
			response.Write(" <a href='"&siteurl&"?"&pageurl&"page="& (CurrentPage-1) &"'>上一页</a> ")
		end if
		%>
		<%
		if Clng(CurrentPage)=Clng(Pager_PageCount) then
			response.Write(" 下一页 ")
			response.Write(" 尾页 ")
		else
			response.Write(" <a href='"&siteurl&"?"&pageurl&"page="& (CurrentPage+1) &"'>下一页</a> ")
			response.Write(" <a href='"&siteurl&"?"&pageurl&"page="& Pager_PageCount &"'>尾页</a> ")
		end if
		%>
		&nbsp;
		<input name="page" type="text" value="<%=CurrentPage%>" size="1" maxlength="10" />
        <input type="submit" name="button" value="跳转" />
        <input type="hidden" name="key" value="<%=key%>" />
        <input type="hidden" name="Itemnumber" value="<%=Itemnumber%>" />
        <input type="hidden" name="SellerID" value="<%=SellerID%>" />
        <input type="hidden" name="uid" value="<%=uid%>" />
        
        <input type="hidden" name="startTime" value="<%=startTime%>" />
        <input type="hidden" name="EndTime" value="<%=EndTime%>" />
        <input type="hidden" name="promark" value="<%=promark%>" />
        
        <input type="hidden" name="mark" value="<%=request.QueryString("mark")%>" />
        <input type="hidden" name="pay" value="<%=pay%>" />
        <input type="hidden" name="search" value="搜索" />
        </form>
      </td>
    </tr>
  </table>
</div>
</div>
</body>
</html>
<%
wid=request.Form("wid")
if wid<>"" then
   if request.Form("button")="保存价格" then
     wid=split(replace(wid," ",""),",")
     for i=0 to ubound(wid)
	 conn.execute("update AuctionsOrder set Realprice='"&request.Form("Realprice"&wid(i))&"',TransferCost='"&request.Form("TransferCost"&wid(i))&"',TransportCost='"&request.Form("TransportCost"&wid(i))&"',ServiceCost='"&request.Form("ServiceCost"&wid(i))&"' where id = "&wid(i)&"")
	 next
	 response.Redirect "product.asp?mark="&request("mark")&"&page="&request.QueryString("page")&""
   end if
   if request.Form("button")="保存商品重量" then
     wid=split(replace(wid," ",""),",")
     for i=0 to ubound(wid)
	 conn.execute("update AuctionsOrder set Weight='"&request.Form("Weight"&wid(i))&"',WarehouseNumber='"&request.Form("WarehouseNumber"&wid(i))&"' where id = "&wid(i)&"")
	 next
	 response.Redirect "product.asp?mark="&request("mark")&"&page="&request.QueryString("page")&""
   end if
   if request.Form("button")="保存付款信息" then
     wid=split(replace(wid," ",""),",")
     for i=0 to ubound(wid)
	 conn.execute("update AuctionsOrder set paymentinfo='"&request.Form("paymentinfo"&wid(i))&"' where id = "&wid(i)&"")
	 next
	 response.Redirect "product.asp?mark="&request("mark")&"&page="&request.QueryString("page")&""
   end if
end if


checkbox=request.Form("checkbox")
if checkbox<>"" then

	if request.Form("button")="待二次付款商品" then
		conn.execute("update AuctionsOrder set mark=2 where id in ("&checkbox&")")
	
	elseif request.Form("button")="已支付商品" then
		conn.execute("update AuctionsOrder set mark=3 where id in ("&checkbox&")")
		
	elseif request.Form("button")="完成支付" then
		conn.execute("update AuctionsOrder set mark=4 where id in ("&checkbox&")")
		
	elseif request.Form("button")="已入库的商品" then
		conn.execute("update AuctionsOrder set mark=5,WarehouseTime='"&now()&"' where id in ("&checkbox&")")
		
	elseif request.Form("button")="已创建包裹的商品" then
		conn.execute("update AuctionsOrder set mark=6,PackageTime='"&now()&"' where id in ("&checkbox&")")
		
	elseif request.Form("button")="日本已寄出商品商品" then
		conn.execute("update AuctionsOrder set mark=7 where id in ("&checkbox&")")	
	
	elseif request.Form("button")="已签收的商品" then
		conn.execute("update AuctionsOrder set mark=8 where id in ("&checkbox&")")
	
	end if
	response.Redirect "product.asp?mark="&request("mark")&"&page="&request.QueryString("page")&""
end if
%>